//
//  WACustomView.m
//  WeatherApp
//
//  Created by Yuliya Grasevych on 02.09.14.
//  Copyright (c) 2014 Yuliya Grasevych. All rights reserved.
//

#import "WACustomView.h"

@implementation WACustomView

- (id)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [NSColor clearColor];
    }
    return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
    [super drawRect:dirtyRect];
    
    if (self.backgroundImage) {
        
        [self.backgroundImage drawInRect:self.bounds
                                fromRect:NSZeroRect
                               operation:NSCompositeSourceOut
                                fraction:1.0
                          respectFlipped:YES
                                   hints:nil];
    }
    else {
        // draw with backgroundColor (clear by default)
        [self.backgroundColor set];
        NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
    }
}

@end
